Rect = Rect or Class("Rect", Vect)

---@diagnostic disable-next-line: duplicate-set-field
function Rect:ctor(x, y, width, height)
    self.x = x
    self.y = y
    self.width = width
    self.height = height
end

function Rect:contains(x, y)
    if x < self.x or x > self.x + self.width or y < self.y or y > self.y + self.height then
        return false
    end
    return true
end

Rect.defineProp("xMax", {
    get = function (self)
        return self.x + self.width
    end,
    set = function (self, key, value)
        self.x = value - self.width
    end
})

Rect.defineProp("yMax", {
    get = function (self)
        return self.y + self.height
    end,
    set = function (self, key, value)
        self.y = value - self.height
    end
})